//@author A0100704B

package crossoff.model;

import java.io.IOException;
import java.util.ArrayList;

import crossoff.db.Storage;

public class GUIobject {

	private static final String MODE_DEFAULT = "TO-DO";
	private static final String FEEDBACK_DEFAULT = "CROSSOFF";
	
	private ArrayList<Task> displayCache;
	private String feedback;
	private String displayInBox;
	private String mode;
	private LFobject livefeed;
	private int toHighlight;
	private int newTask;
	
	public GUIobject() throws IOException{
		displayCache = Storage.getInstance().taskCache;
		feedback = FEEDBACK_DEFAULT;
		displayInBox = "";
		mode = MODE_DEFAULT;
		livefeed = null;
		toHighlight = 0;
		newTask = 0;
	}
	
	public GUIobject(ArrayList<Task> displayCache, String feedback, String displayInBox, String mode){
		this.displayCache = displayCache;
		this.feedback = feedback;
		this.displayInBox = displayInBox;
		this.mode = mode;
		this.livefeed = null;
		toHighlight = 0;
		newTask = 0;
	}
	
	public GUIobject(ArrayList<Task> displayCache, String feedback, String displayInBox, String mode, LFobject livefeed){
		this.displayCache = displayCache;
		this.feedback = feedback;
		this.displayInBox = displayInBox;
		this.mode = mode;
		this.livefeed = livefeed;
		toHighlight = 0;
		newTask = 0;
	}
	
	public GUIobject(ArrayList<Task> displayCache, String feedback, String displayInBox, String mode, LFobject livefeed, int toHighlight){
		this.displayCache = displayCache;
		this.feedback = feedback;
		this.displayInBox = displayInBox;
		this.mode = mode;
		this.livefeed = livefeed;
		this.toHighlight = toHighlight;
		newTask = 0;
	}
	
	public GUIobject(ArrayList<Task> displayCache, String feedback, String displayInBox, String mode, LFobject livefeed, int toHighlight, int newTask){
		this.displayCache = displayCache;
		this.feedback = feedback;
		this.displayInBox = displayInBox;
		this.mode = mode;
		this.livefeed = livefeed;
		this.toHighlight = toHighlight;
		this.newTask = newTask;
	}
	
	public GUIobject(ArrayList<Task> displayCache, String feedback, String displayInBox){
		this.displayCache = displayCache;
		this.feedback = feedback;
		this.displayInBox = displayInBox;
		mode = MODE_DEFAULT;
		livefeed = null;
		toHighlight = 0;
		newTask = 0;
	}
	
	public GUIobject(String feedback, String displayInBox) throws IOException{
		displayCache = Storage.getInstance().taskCache;
		this.feedback = feedback;
		this.displayInBox = displayInBox;
		mode = MODE_DEFAULT;
		livefeed = null;
		toHighlight = 0;
		newTask = 0;
	}
	
	public GUIobject(String feedback, String displayInBox, int toHighlight) throws IOException{
		displayCache = Storage.getInstance().taskCache;
		this.feedback = feedback;
		this.displayInBox = displayInBox;
		mode = MODE_DEFAULT;
		livefeed = null;
		this.toHighlight = toHighlight;
		newTask = 0;
	}
	
	public GUIobject(LFobject livefeed) throws IOException{
		this.displayCache = Storage.getInstance().taskCache;
		this.feedback = FEEDBACK_DEFAULT;
		this.mode = MODE_DEFAULT;
		this.livefeed = livefeed;
		toHighlight = 0;
		newTask = 0;
	}
	
	public int getTaskPosition(int taskID){
		if(displayCache != null){
			for(int i = 0; i < displayCache.size(); i++){
				if(displayCache.get(i).getTaskID() == taskID){
					return i;
				}
			}
		}
		return 0;
	}
	
	public ArrayList<Task> getDisplayCache(){
		return displayCache;
	}
	
	public String getFeedback(){
		return feedback;
	}
	
	public String getDisplayInBox(){
		return displayInBox;
	}
	
	public String getMode(){
		return mode;
	}
	
	public LFobject getLiveFeed(){
		return livefeed;
	}

	public int getToHighlight() {
		return toHighlight;
	}
	
	public void setFeedback(String feedback) {
		this.feedback = feedback;
	}

	public int getNewTask(){
		return newTask;
	}
	
	public void setMode(String mode){
		this.mode = mode;
	}

	public void setToHighlight(int toHighlight) {
		this.toHighlight = toHighlight;
	}
	
	public void setNewTask(int newTask){
		this.newTask = newTask;
	}
}
